<template>
    <div class="box2">孙组件2
     {{ user.name }}

     <button @click="update">修改</button>
    </div>
    </template>
    <script setup lang='ts'> 
     import {ref,reactive, inject} from 'vue';
     const user= inject<any>("user");
     const update=()=>{
         user.value.name="小王";
     }
    </script>
    <style scoped lang='less'>
    .box2{
        width: 100%;
        height: 100px;
        background-color: yellow;
    }
    </style>